MBasic: LCD Commands
LCD Commands Intro Important:' The LCD commands in this section are specifically designed for use with the Hitachi 44780 controller (or equivalent). If you use an LCD module with a different controller, these commands probably will not work. In such cases, you can write your own subroutines to initialize your LCD and send output to it. A detailed explanation of the Hitachi LCD controller is beyond the scope of this manual. The 44780 controller is use for text-mode displays, these commands don't apply to graphical LCD displays. Conventions Used in this Chapter ''Important: Several of the commands described in this chapter specifically address hardware features of the microcontroller chip. Descriptions of these hardware features are beyond the scope of this manual. Please refer to the H8/3664F or H8/3687F hardware manual, available at http://www.renesas.com for further details.'' LCDINIT Initializes an LCD display. This command must be used before using the LCDREAD or LCDWRITE commands. '''''Syntax :lcdinit regsel\clk\D7\D6\D5\D4\RdWrPin ::regsel is a constant or variable specifying the Atom Pro I/O pin connected to the LCD's R/S line. ::clk is a constant or variable specifying the Atom Pro I/O pin connected to the LCD's E (Enable) line. ::D7 - D4 are constants or variables that specify the Atom Pro pins to use for the LCD data lines. ::RdWrPin is an optional constant or variable specifying the Atom Pro I/O pin connected to the R/W (read/write) line of the LCD. Examples If your LCD display uses the following connections: The command: lcdinit p4\p5\p3\p2\p1\p0\p6 will initialize the display for future LCDREAD and LCDWRITE commands. LCDREAD Reads the RAM on an LCD module using the Hitachi 44780 controller or equivalent. Important:' You must initialize the display with LCDINIT before using this command. '''''Syntax :ldcread regsel\clk\D7\D6\D5\D4,RdWrPin, address, var ::regsel is a constant or variable specifying the Atom Pro I/O pin connected to the LCD's R/S line. ::clk is a constant or variable specifying the Atom Pro I/O pin connected to the LCD's E (Enable) line. ::D7 - D4 are constants or variables specifying the Atom Pro I/O pins connected to the LCD’s data lines (see lcdinit). ::RdWrPin is a constant or variable specifying the Atom Pro I/O pin connected to the R/W (read/write) line of the LCD. ::address is a constant or variable that specifies the RAM location to be read, according to this list: ::modifiers are command modifiers (see Chapter 8 - Command Modifiers) used to modify var. ::var is a byte variable (or a comma - separated list of variables) where the returned value will be stored. Examples If your LCD display uses the same connections as shown under LCDINIT, the program segment: character var byte lcdread p4\p5\p3\p2\p1\p0\p6,15,character will read the character stored at RAM address 15 and save it in character. LCDWRITE Sends text output to an LCD display module that uses the Hitachi 44780 controller or equivalent. Important:' You must initialize the display with LCDINIT before using this command. '''''Syntax :lcdwrite regsel\clk\D7\D6\D5\D4,{RdWrPin,} expr ::regsel is a constant or variable specifying the Atom Pro I/O pin connected to the LCD's R/S line. ::clk is a constant or variable specifying the Atom Pro I/O pin connected to the LCD's E (Enable) line. ::D7 - D4 are constants or variables specifying the Atom Pro I/O pins connected to the LCD’s data lines (see lcdinit). ::RdWrPin is an optional constant or variable specifying the Atom Pro I/O pin connected to the R/W (read/write) line of the LCD. ::modifiers are command modifiers (see Chapter 8 - Command Modifiers) used to modify expr. ::expr is a variable, constant or expression that generates the data to be written. Data may be text characters or commands. A list of commands is given under Notes, below. Notes Here is a list of commands that can be used with the LCDWRITE command. Multiple commands may be included inside [ ... ] if they are comma separated. Examples If your LCD display uses the same connections as shown under LCDINIT, the program segment: printch var byte printch = $41 ; ASCII value for "A" lcdwrite p4\p5\p3\p2\p1\p0,p6, clear,home,printch will clear the screen, move to the home position, and print an A on the display.